<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" type="text/css" th:href="@{/plugins/element/index.css}"/>
<link rel="stylesheet" type="text/css" th:href="@{/css/login.css}"/>
<link rel="stylesheet" type="text/css" th:href="@{/css/base.css}"/>
<title>SBOOTV</title>
</head>
<body>
<div class="login-main">
	<div class="login-form" id="login_form">
		<form id="login">
			<div class="logn-form-item">
				<div class="logn-from-input">
					<label>账号</label>
					<input type="text" name="username" id="username" value="1" maxlength="20"/>
				</div>
			</div>
			<div class="logn-form-item">
				<div class="logn-from-input">
					<label>密码</label>
					<input type="password" name="password" id="password" value="1" maxlength="20"/>
				</div>
			</div>
			<div class="logn-form-item">
                <div class="logn-form-submit" id="submit">
                    <a id="logn_form_submit">登录</a>
                </div>
            </div>
		</form>
	</div>
</div>
<script th:src="@{/plugins/jquery/jquery-1.11.3.min.js}"></script>
<script th:src="@{/js/init.js}"></script>
<script type="text/javascript">
$(function(){
	$("#submit").click(function(){
		$('.logn-from-input').removeClass('error');
		var formData = {};
		formData.username = $("#username").val();
		formData.password = $("#password").val();
		$.ajax({
			url:SBOOTV.realPath+"/ajaxLogin",
			method:'post',
			data:formData,
			dataType:'json',
			success:function(data){
				if(!!!data){
					alter("未知错误!");
					return;
				}
				if(data.code === 0){
					window.location.href = "index";
				}
				if(data.code != 0){
					if(data.msg == '账号不存在！'){
						$("#username").parent().addClass('error');
					}else{
						$("#password").parent().addClass('error');
					}
					alert(data.msg);
				}
			}
		});
	});
});
</script>
</body>
</html>